<?php
/**
 * 手机发送验证码
 */
//use message\lib\messagesend;
use message\lib\messagexsend;
use think\Session;
function sendcode($phone,$code,$type){
    $submail = new messagexsend(config('message_config'));

    $submail->setTo($phone);
    switch ($type){
        case 0:
        $message_template = 'v1m2N';
        break;
        case 1:
        $message_template = 'oZesy3';
    }
    $submail->SetProject($message_template);

    $submail->AddVar('code',$code);
//    $submail->SetContent('【SUBMAIL】您的短信验证码：4438，请在10分钟内输入。');
    $res = $submail->xsend();

    return $res;
}

/*function SUBMAILAutoload($classname){
    $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'lib/'.strtolower($classname).'.php';
    if (is_readable($filename)) {
        require $filename;
    }
}

if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
    if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
        spl_autoload_register('SUBMAILAutoload', true, true);
    } else {
        spl_autoload_register('SUBMAILAutoload');
    }
} else {
    //function __autoload($classname){
    function spl_autoload_register($classname){
        SUBMAILAutoload($classname);
    }
}*/